var request_id;

function addOnLoad(v) {
	$(document).ready(function(){
		v();
	});
}


function orederCall() {
	$.ajax({
		type: 'POST',
		url: HTTP_HOST + '/index/order-call',
		data: {},
		success: function(data, textStatus){
			showModalWindow(data);			
		},
		dataType: 'json'
	});
}

function sendOrderCall(){
	var param = {};
	param.name = $("#order-call_div input[name=name]").val();
	param.phone = $("#order-call_div input[name=phone]").val();
	param.msg = $("#order-call_div textarea[name=msg]").val();
	param.time = $("#order-call_div input[name=time]").val();
	$('#RegionID').children().remove();
	$.ajax({
		type: 'POST',
		url: HTTP_HOST+'/index/order-call-msg',
		data: {arr: param},
		success: function(data, textStatus){
			hideModalWindow();
		},
		dataType: 'json'
	});
}

function requestView(id) {
	this.request_id = id;
	$.ajax({
		type: 'POST',
		url: HTTP_HOST + '/index/request-view',
		data: {},
		success: function(data, textStatus){
			showModalWindow(data);
		},
		dataType: 'json'
	});
}

function sendRequest(){
	var param = {};
	param.ObjectID = request_id;
	param.name = $("#order-call_div input[name=name]").val();
	param.surname = $("#order-call_div input[name=surname]").val();
	param.phone = $("#order-call_div input[name=phone]").val();
	param.mail = $("#order-call_div input[name=mail]").val();
	$('#RegionID').children().remove();
	$.ajax({
		type: 'POST',
		url: HTTP_HOST+'/index/request-msg',
		data: {arr: param},
		success: function(data, textStatus){
			hideModalWindow();
		},
		dataType: 'json'
	});
}

function reloadRegions(country) {
	$('#RegionID').children().remove();
	$.ajax({
		type: 'POST',
		url: HTTP_HOST + '/site-manager/object/reload-regions',
		data: {id:country},
		success: function(data, textStatus){
			for (i in data.RegionID) $('#RegionID').append($('<option />').val(i).html(data.RegionID[i])); 
		},
		dataType: 'json'
	});
}

function showRegions(data) {
	for (i in data.RegionID) $('#RegionID').append($('<option />').val(i).html(data.RegionID[i])); 
}

function individualSelection(){
	window.location.href = HTTP_HOST+'/service-action/success-sending';
}

function hideModalWindow() {
	$('#popup').remove();
	$('#totalshadow').remove();
}

function showModalWindow(data) {
	var div = $('<div id="popup"/>').css({position: 'absolute', top: $(document).scrollTop() + 100, width: data.width + 'px', left: '50%', 'z-index': 10025, background: '#FFF'});
	div.css('margin-left', -data.width / 2);
	div.append(data.html);
	$('body').append('<div id="totalshadow" class="totalshadow"></div>');
	$("#totalshadow").width($(document).width()).height($(document).height() + $(document).scrollTop());
	$('body').append(div);
}

//right_menu_one_button
//menu_btn
